/*
 * CSSException.cpp
 *
 *  Created on: 2010-8-28
 *      Author: Xairy
 */

#include "CSSException.h"

const string CSSException::S_SAC_UNSPECIFIED_ERR = "unknown error";
const string CSSException::S_SAC_NOT_SUPPORTED_ERR = "not supported";
const string CSSException::S_SAC_SYNTAX_ERR = "syntax error";

CSSException::CSSException(CSSException::CodeType _code, const string* _s)
	:code(_code)
{
	if(_s)
		s = *_s;
}

CSSException::~CSSException()throw()
{

}

const string* CSSException::getMessage()const
{
	if(!s.empty())
		return &s;
	else
	{
		switch(code)
		{
		case SAC_UNSPECIFIED_ERR: return &S_SAC_UNSPECIFIED_ERR;
		case SAC_NOT_SUPPORTED_ERR: return &S_SAC_NOT_SUPPORTED_ERR;
		case SAC_SYNTAX_ERR: return &S_SAC_SYNTAX_ERR;
		default:
			return NULL;
		}
	}
}


